//导入request.js文件
import request from '@/utils/request.js'

//提供注册接口处理的函数
export const userRejisterService = (rejisterData) => {
    //借助于UrlSearchParmas完成参数传递
    const params = new URLSearchParams()
    for (let key in rejisterData) {
        params.append(key, rejisterData[key]);
    }
    return request.post('/user/register', params)
}

//提供登录接口
export const userLoginService = (loginData) => {
    //借助于UrlSearchParmas完成参数传递
    const params = new URLSearchParams()
    for (let key in loginData) {
        params.append(key, loginData[key]);
    }
    return request.post('/user/login', params)
}

//获取用户详情信息
export const userinfoService = () => {
    return request.get('/user/userInfo')
}

//修改给个人信息
export const userInfoUpdateService = (userInfoData) => {
    return request.put('/user/update', userInfoData)
}

//修改头像
export const userAvatarUpdateService = (avatarUrl) => {
    const params = new URLSearchParams();
    params.append('avatarUrl', avatarUrl)
    return request.patch('/user/updateAvatar', params)
}